package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.domain.entity.TAdsbHistoryData;
import com.ruoyi.system.mapper.AdsbHistoryDataMapper;
import com.ruoyi.system.service.IAdsbHistoryDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

/**
 * @Auther: Stanley.Y
 * @Date: 2024/7/12
 * @Description:
 * @Version 1.0.0
 */

@Service
public class AdsbHistoryDataServiceImpl implements IAdsbHistoryDataService {
    private static final Logger log = LoggerFactory.getLogger(AdsbHistoryDataServiceImpl.class);

    @Autowired
    private AdsbHistoryDataMapper adsbHistoryDataMapper;
    @Override
    public int saveInitParams(TAdsbHistoryData tAdsbHistoryData){return adsbHistoryDataMapper.saveInitParams(tAdsbHistoryData);};

    public void updateStatusAndResultByID(int id, String newStatus, String newResult) {
        // 根据创建时间查询记录
        TAdsbHistoryData record = adsbHistoryDataMapper.findByID(id);

        if (record != null) {
            // 更新status和result字段
            record.setStatus(newStatus);
            record.setResult(newResult);
            adsbHistoryDataMapper.updateStatusAndResult(record);
        }
    };
    public List<TAdsbHistoryData> getLatestNRecords(int lastCount) {
        return adsbHistoryDataMapper.findLatestNRecords(lastCount);
    }
}
